package com.copsoftware.mantenimientos.acusado.assemblers;

import org.springframework.beans.BeanUtils;

import com.copsoftware.mantenimientos.acusado.beans.Acusado;
import com.copsoftware.mantenimientos.acusado.beans.AcusadoInvestigacion;
import com.copsoftware.struts.forms.RegistrarAcusadoInvestigacionForm;


public class AcusadoAssembler {

	public static Acusado createAcusado(RegistrarAcusadoInvestigacionForm form) {
		
		Acusado acusadoFlt= new Acusado();
		BeanUtils.copyProperties(form, acusadoFlt,new String []{"CInvestigacion", "CPersona", "CBanda"});
		
		if (form.getCBanda() != null)
		 acusadoFlt.setCBanda(Integer.parseInt(form.getCBanda()));
			
		if (!form.getCPersona().equals(""))
		{
			acusadoFlt.setCPersona(Integer.parseInt(form.getCPersona()));
		}
		
		return acusadoFlt;
	}
	
	public static AcusadoInvestigacion createAcusadoInvestigacion(RegistrarAcusadoInvestigacionForm form){
		
		AcusadoInvestigacion acusadoInvestigacion = new AcusadoInvestigacion();
		
		if (!form.getCInvestigacion().equals(""))
			acusadoInvestigacion.setCInvestigacion(Integer.parseInt(form.getCInvestigacion()));
		
		if (!form.getCPersona().equals(""))
			acusadoInvestigacion.setCPersona(Integer.parseInt(form.getCPersona()));
		
		acusadoInvestigacion.setXDeclaracion(form.getXDeclaracion());
		acusadoInvestigacion.setXObservacion(form.getXObservacion());
		
			
		return acusadoInvestigacion;
		
	}
	
}
